package team.product.utils;

import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.Serializable;

/**
 * Created with IntelliJ IDEA.
 * User: Lương Xuân Huy
 * Date: 9/17/14
 * Time: 4:49 PM
 * Long Van Soft Solution Sjc.
 * To change this template use File | Settings | File and Code Templates
 */
public class FaceUtils implements Serializable {

    public static HttpServletRequest getRequest() {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        if (null == facesContext) return null;
        ExternalContext externalContext = facesContext.getExternalContext();
        if (null == externalContext) return null;
        return (HttpServletRequest) externalContext.getRequest();
    }
    public static HttpSession getSession() {
        HttpServletRequest request = getRequest();
        if (null != request) return (HttpSession) getRequest().getSession();
        return null;
    }
}
